<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="spring" uri="/WEB-INF/tlds/spring.tld"%>
<%@ taglib prefix="c" uri="/WEB-INF/tlds/c.tld"%>
<c:set var="BasePath" value="${pageContext.request.contextPath}"></c:set>
<c:set var="Plugins" value="${pageContext.request.contextPath}/res/plugins"></c:set>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>货品规格选项</title>
<link href="${Plugins}/ligerUI/skins/Aqua/css/ligerui-all.css" rel="stylesheet" type="text/css" />
<link href="${Plugins}/ligerUI/skins/ligerui-icons.css" rel="stylesheet" type="text/css" />
<script src="${Plugins}/datepicker/WdatePicker.js" type="text/javascript"></script>
<script src="${Plugins}/jquery/jquery-1.3.2.min.js"	type="text/javascript"></script>
<script src="${Plugins}/ligerUI/js/ligerui.min.js" type="text/javascript"></script>
<script src="${Plugins}/jquery-validation/jquery.metadata.js" type="text/javascript"></script>
<script src="${Plugins}/jquery-validation/jquery.validate.js" type="text/javascript"></script>
<script src="${BasePath}/res/js/common/jquery.form.js" type="text/javascript"></script>
<script src="${BasePath}/res/js/common/utils.js" type="text/javascript"></script>
<style type="text/css">
#searchbar{
	margin-bottom: 10px;
}
.navbar {
		height: 20px;
		border-bottom: #E6E6E6 solid 1px;
		line-height: 20px;
	}
.l-button-search{
	width: 50px;
	margin-left: 10px;
	padding-bottom: 2px;
	display: inline;
}
</style>
</head>
<body style="padding:6px; overflow:hidden;">
<div id="">
	<div class="navbar"><span>商品管理 &gt;规格管理 &gt;规格选项 </span></div>
	<br/>
	<form action="saveOption.do"  name="queryForm" id="queryForm" method="POST">
		<input type="hidden" id="opType" name="opType" value="${opType}">
		<input type="hidden" id="specNo" name="specNo" value="${option.specNo}">
		<input type="hidden" id="optionNo" name="optionNo" value="${option.optionNo}">
		<table cellpadding="0" cellspacing="0" class="l-table-edit" >
		    <tr height="15"></tr>
		    <tr>
		        <td align="left" class="l-table-edit-td"><font  color="red">*</font>选项值：</td>
		        <td align="left" class="l-table-edit-td" colspan="2">
		        	<input type="text" class="l-textarea" id="optionName" name="optionName" value="${option.optionName}" validate="{required:true}" >
		        </td>
		    </tr>
		</table><br>
		<input  type="submit" value="确定" class="l-button-search" style="margin-left: 70px;">&nbsp;&nbsp;&nbsp;&nbsp;<input  type="button" id="cancelButton" value="取消" class="l-button-search" >
	</form>
	<br/>
</div>
<div id="maingrid6" style="margin:0; padding:0"></div>
  <div style="display:none;">
  <!-- g data total ttt -->
</div>
<script type="text/javascript">
$(function ()
		{
			//validate
		    $.metadata.setType("attr", "validate");
		    var v = $("form").validate({
		        errorPlacement: function (lable, element)
		        {
		        	lable.ligerHideTip();
		            if (element.hasClass("l-textarea"))
		            {
		                element.ligerTip({ content: lable.html(), target: element[0] }); 
		            }
		            else if (element.hasClass("l-text-field"))
		            {
		                element.parent().ligerTip({ content: lable.html(), target: element[0] });
		            }
		            else
		            {
		                lable.appendTo(element.parents("td:first").next("td"));
		            }
		        },
		        success: function (lable)
		        {
		            lable.ligerHideTip();
		            lable.remove();
		        },
		        submitHandler:function()
		        {
		            $("form .l-text,.l-textarea").ligerHideTip();
		            var options = {
		            		type: 'POST',
		            		dataType: 'json',
		            		success: function(data){
		            			if(data.res.toLowerCase() == "success") {
		            				if($("#opType").val() == "add") {
		            					parent.window.addOption(data.optionNo, StringUtils.trim($("#optionName").val()));
		            				} else if($("#opType").val() == "update") {
		            					parent.window.editOption(data.optionNo, StringUtils.trim($("#optionName").val()));
		            				}
		            				closeCurWindow();
		            			} else {
		            				alert("保存失败");
		            				closeCurWindow();
		            			}
		            			
		            		}
		            	}, $form1 = $("#queryForm");
		           $form1.ajaxSubmit(options);
		             return false;
		        }
		    });
		}); 
// 取消
$("#cancelButton").click(function() {
	closeCurWindow();
});
function closeCurWindow() {
	parent.$.ligerDialog.close();
	parent.$(".l-dialog,.l-window-mask").remove();
}
</script>
</body>
</html>